﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExtensionControls
{
    abstract public class BaseViewModelCollection<T,C> where T : IViewModel<C>
    {
        protected List<T> _Items;
        protected List<C> _Columns;

        public List<T> Items
        {
            get
            {
                return this._Items;
            }
        }

        public List<C> Columns
        {
            get
            {
                return this._Columns;
            }
        }

        public BaseViewModelCollection()
        {
            this._Items = new List<T>();
            this._Columns = new List<C>();
        }

        public void AddItem(T Item)
        {
            this._Items.Add(Item);
        }

        public void AddItem(List<T> Items)
        {
            this._Items.AddRange(Items);
        }


        public void AddColumn(C Column)
        {
            this._Columns.Add(Column);
        }

        public void AddColumn(List<C> Columns)
        {
            this._Columns.AddRange(Columns);
        }

        public abstract List<ExtensionGridColumnHeader> GetColumnsType();

        public IEnumerable<object> getRowData()
        {
            foreach (T item in this._Items)
            {
                yield return item.getColumns(this._Columns);
            }
        }
    }
}
